<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <script src="/js/axios.min.js"></script>
  <script src="/js/util.js"></script>
  <script>
    function add(){
      var formObj = new FormData();
      formObj.append("name",$("nameTxt").value);
      formObj.append("price",$("priceTxt").value);
      formObj.append("pic",$("picture").files[0]);

      var config = {
        headers:{'Content-Type' : 'multipart/form-data'}
      };
      axios.post("/product/add",formObj,config).then(resp =>{
        if(resp.data == "ok"){
            location.href = "/product/index.html";
        }
      });
    }
  </script>
</head>
<body>
    商品名：<input type="text" id="nameTxt"><br>
    单价：<input type="text" id="priceTxt"><br>
    图片：<input type="file" id="picture"><br>
    <input type="button" value="添加" onclick="add()">
</body>
</html>